<template>
  <div class="app-container">
   <el-form :inline="true" ref="ruleForm"  :model="formInline" class="demo-form-inline">
    <el-form-item label="数据补录时间" prop="time">
      <el-date-picker
      class="date-picker-box"
        v-model="formInline.time"
        type="datetimerange"
        align="right"
        unlink-panels
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="yyyy-MM-dd HH:mm:ss"
        :default-time="['00:00:00', '23:59:59']"
        :picker-options="pickerWeekStep" >
      </el-date-picker>
      </el-form-item>
      <el-form-item label="任务执行时间"  prop="jobTime">
          <el-date-picker
          class="date-picker-box"
            v-model="formInline.jobTime"
            type="datetimerange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd HH:mm:ss"
            :default-time="['00:00:00', '23:59:59']"
            :picker-options="pickerWeekStep" >
          </el-date-picker>
      </el-form-item>
       <el-form-item label="游戏平台" prop="gamePlatform">
        <el-select v-model="formInline.gamePlatform"   placeholder="请选择"  style="width:200px">
          <el-option
            v-for="item in GAME_PLATFORM_LIST.filter((item)=>{return item.type.includes('dataAddRecord')})"
            :label="item.title"
            :key="item.value"
            :value="item.value"
             checked
          ></el-option>
        </el-select>
      </el-form-item>
       <el-form-item label="数据类型" prop="dataType">
        <el-select v-model="formInline.dataType"   placeholder="请选择"  style="width:200px">
          <el-option
            v-for="item in DATA_TYPE_LIST"
            :label="item.title"
            :key="item.value"
            :value="item.value"
             checked
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="任务状态" prop="status">
        <el-select v-model="formInline.status"   placeholder="请选择"  style="width:200px">
          <el-option
            v-for="item in JOP_STATUS_LIST"
            :label="item.title"
            :key="item.value"
            :value="item.value"
             checked
          ></el-option>
        </el-select>
      </el-form-item>

      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="toSearch">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>
<script>
import { form, grid, pickerOption } from '@/build';
import { GAME_PLATFORM_LIST, DATA_TYPE_LIST, JOP_STATUS_LIST } from './data';

export default {
  name: 'form-filter',
  mixins: [form, grid, pickerOption],
  data() {
    return {
      GAME_PLATFORM_LIST,
      DATA_TYPE_LIST,
      JOP_STATUS_LIST,
      formInline: {
        jobTime: [],
        time: [
          moment().format('YYYY-MM-DD 00:00:00'),
          moment().format('YYYY-MM-DD 23:59:59'),
        ],
        gamePlatform: undefined,
        dataType: undefined,
        status: undefined,
        page: 1,
        size: 20,
      },
    };
  },
  methods: {
    toSearch() {
      this.$emit('on-filter', this.formInline);
    },
    selfResetForm(formName) {
      this.resetForm(formName);
      this.$emit('on-filter', this.formInline);
    },
  },

  mounted() {
    // window.addEventListener('keyup', (e) => {
    //   const event = e || window.event;
    //   const code = event.keyCode || event.which || event.charCode;
    //   if (code == 13) {
    //     this.toSearch();
    //   }
    // });
  },
};
</script>

<style lang="scss" scoped>

</style>
